package cn.edu.hqu.cst.android.recyclerviewtest;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import java.util.ArrayList;
import java.util.List;

import cn.edu.hqu.cst.android.recyclerviewtest.adapters.ListViewAdapter;
import cn.edu.hqu.cst.android.recyclerviewtest.beans.Datas;
import cn.edu.hqu.cst.android.recyclerviewtest.beans.ItemBean;

import static androidx.recyclerview.widget.LinearLayoutManager.*;

public class MainActivity extends AppCompatActivity {

    private static final String TAG ="MainActivity" ;
    private RecyclerView mList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //找到控件
      mList=(RecyclerView)this.findViewById(R.id.recycler_view);
       initData();
    }
 //该方法用于模拟数据
    private void initData() {
       List<ItemBean> mData = new ArrayList<>();
     //list<DataBeans>
        for(int i=0;i<Datas.icons.length;i++){


            ItemBean data=new ItemBean();
            data.icon=Datas.icons[i];
            data.title="我是第 "+ i + " 个条目";
            mData.add(data);


        }

    LinearLayoutManager layoutManager=new LinearLayoutManager(this);
        mList.setLayoutManager(layoutManager);


        
        ListViewAdapter adapter=new ListViewAdapter(mData);
        mList.setAdapter(adapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        return super.onCreateOptionsMenu(menu);
    }

    @SuppressLint("NonConstantResourceId")
    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {

            return super.onOptionsItemSelected(item);
    }
}